﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GroupRadar : MonoBehaviour {

    private Collider[] m_aCollider;
    public float m_fRadius;
    public LayerMask layerChecked;
    public List<GameObject> m_lisObjs;

    public void FreshNeighbors()
    {
        m_aCollider = Physics.OverlapSphere(transform.position, m_fRadius, layerChecked);
        m_lisObjs.Clear();
        for (int i = 0; i < m_aCollider.Length; i++)
        {
            if(m_aCollider[i].gameObject.GetInstanceID() != gameObject.GetInstanceID())
            {
                m_lisObjs.Add(m_aCollider[i].gameObject);
            }
        }
    }

    public List<GameObject> GetNeighbors()
    {
        return m_lisObjs;
    }

    void OnDrawGizmos()
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(transform.position, m_fRadius);
    }
}
